#include "include/controls/noticebox/cxinoticebox.h"
#include <private/noticebox/cxinoticebox_p.h>
CxiNoticeBox::CxiNoticeBox()
	: d_ptr(new CxiNoticeBoxPrivate(this))
{
	Q_D(CxiNoticeBox);
	d->init();
}
CxiNoticeBox::~CxiNoticeBox() = default;
CxiNoticeBox& CxiNoticeBox::instance()
{
	static CxiNoticeBox instance;
	return instance;
}
void CxiNoticeBox::show(const NoticeData& data)
{
	CxiNoticeBox::instance().d_ptr->addNoticeWidget(data);
}
void CxiNoticeBox::showNotice(const QString& text, int autoPopDelay, const QString& caption)
{
	CxiNoticeBox::instance().d_ptr->addNotice(text, autoPopDelay, caption, NoticeType::Notice);
}
void CxiNoticeBox::showMessage(const QString& text, int autoPopDelay, const QString& caption)
{
	CxiNoticeBox::instance().d_ptr->addNotice(text, autoPopDelay, caption, NoticeType::Message);
}
void CxiNoticeBox::showRemind(const QString& text, int autoPopDelay, const QString& caption)
{
	CxiNoticeBox::instance().d_ptr->addNotice(text, autoPopDelay, caption, NoticeType::Remind);
}
void CxiNoticeBox::showWarning(const QString& text, int autoPopDelay, const QString& caption)
{
	CxiNoticeBox::instance().d_ptr->addNotice(text, autoPopDelay, caption, NoticeType::Warning);
}
void CxiNoticeBox::showConfirm(const QString& text, std::function<void()> confirmCallback, int autoPopDelay, const QString& caption, const QString& btnText)
{
	CxiNoticeBox::instance().d_ptr->addConfirm(text, confirmCallback, autoPopDelay, caption, btnText);
}
void CxiNoticeBox::showMQ(const QVariant& mqData, std::function<void(const QVariant&)> mqClickCallback, std::function<void(const QVariant&)> mqDoubleClickCallback, int autoPopDelay, const QString& caption)
{
	CxiNoticeBox::instance().d_ptr->addMQ(mqData, mqClickCallback, mqDoubleClickCallback, autoPopDelay, caption);
}
void CxiNoticeBox::setAllowShowNewMsg(bool allow)
{
	CxiNoticeBox::instance().d_ptr->m_allowShowNewMsg = allow;
	CxiNoticeBox::instance().d_ptr->showNotices();
}
void CxiNoticeBox::clearAll()
{
	CxiNoticeBox::instance().d_ptr->removeAllNotices();
}
void CxiNoticeBox::setMaxVisibleCount(int max)
{
	CxiNoticeBox::instance().d_ptr->m_maxVisibleCount = max;
	CxiNoticeBox::instance().d_ptr->showNotices();
}
int CxiNoticeBox::maxVisibleCount()
{
	return CxiNoticeBox::instance().d_ptr->m_maxVisibleCount;
}